package com.example.dou2204.utils;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

public class DiyRecyclerView extends RecyclerView {
    private boolean intercept = true;//默认值  拦截

    public void setIntercept(boolean intercept) {
        this.intercept = intercept;
    }

    public DiyRecyclerView(@NonNull Context context) {
        super(context);
    }

    public DiyRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public DiyRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent e) {
        if(intercept){
            return super.onInterceptTouchEvent(e);
        }else{
            return false;
        }
    }
}
